@echo off

set APP_JAR=mts.da-1.0.jar

set ID=
    IF "%1%"=="start" GOTO start
    IF "%1%"=="stop" GOTO stop
    IF "%1%"=="restart" GOTO restart
    IF "%1%"=="exit" EXIT
PAUSE

:start
    call :startApp
    GOTO :eof

:stop
    call :stopApp
    GOTO :eof

:restart
    call :stopApp
    call :startApp
    GOTO :eof

:startApp
    IF NOT EXIST "%APP_JAR%" ECHO "%APP_JAR%" is not exist.

    IF EXIST "%APP_JAR%" (
        set "now=%date:~,4%%date:~5,2%%date:~8,2%"
        echo "Start server, see details in log/server.log"
        java -jar %APP_JAR% >> log/server.log
    )
:stopApp
    IF NOT EXIST "%APP_JAR%" ECHO "%APP_JAR%" is not exist.
    taskkill /F /IM java > nul